package com.xm.web.controller.system;

import com.xm.common.entity.LoginRequest;
import com.xm.common.entity.R;
import com.xm.web.service.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 登录
 *
 * @author yousj
 * @since 2021/8/18
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/door")
@Api(tags = "登录")
public class LoginController {

    private final LoginService loginService;

    @ApiOperation(value = "登录")
    @PostMapping("/login")
    public R login(@RequestBody LoginRequest loginRequest) {
        return R.isOk(loginService.login(loginRequest));
    }

    @ApiOperation(value = "退出")
    @GetMapping("/logout")
    public R logout() {
        return R.isOk(loginService.logout());
    }

}
